package com.zzy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.system.domain.PurchaseRefundOrderDetails;
import com.zzy.system.mapper.PurchaseRefundOrderDetailMapper;
import com.zzy.system.service.IPurchaseRefundOrderDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurchaseRefundOrderDetailServiceImpl extends ServiceImpl<PurchaseRefundOrderDetailMapper, PurchaseRefundOrderDetails> implements IPurchaseRefundOrderDetailService {
    private static final Logger log = LoggerFactory.getLogger(PurchaseRefundOrderDetailServiceImpl.class);

    @Override
    public void saveRefundOrderDetail(List<PurchaseRefundOrderDetails> purchaseRefundOrderDetails) {
        if(purchaseRefundOrderDetails.size()>0){
            QueryWrapper<PurchaseRefundOrderDetails> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("supplier_refund_sheet_id", purchaseRefundOrderDetails.get(0).getSupplierRefundSheetId());
            baseMapper.delete(queryWrapper);
            this.saveBatch(purchaseRefundOrderDetails);
        }

    }
}